package com.juicygames.shmup.player;

import android.graphics.Color;
import android.graphics.Rect;

import com.juicygames.framework.draw.DrawDepth;
import com.juicygames.framework.draw.drawservice.DrawService;
import com.juicygames.framework.draw.sprite.Animation;
import com.juicygames.framework.draw.sprite.SpriteDrawer;
import com.juicygames.framework.gamepart.GameEntity;
import com.juicygames.framework.gamepart.GamePart;
import com.juicygames.framework.property.space.ColorProperty;
import com.juicygames.framework.property.space.Position;
import com.juicygames.framework.property.space.TouchBoundingBox;
import com.juicygames.framework.property.space.Velocity;
import com.juicygames.framework.touch.EntityTouchService;
import com.juicygames.shmup.player.anim.PickUpRockAnim;
import com.juicygames.shmup.player.anim.StandAnim;
import com.juicygames.shmup.player.anim.ThrowRockAnim;
import com.juicygames.shmup.player.anim.WalkAnim;

public class Player extends GameEntity {
	
	private static final int DRAW_DEPTH = 9;
	private static final int COLOR = Color.RED;
	
	public void load() {
		addPart(new Position(50, 50));
		addPart(new Velocity());
		
		addPart(new Follower());
		
		addPart(new TouchBoundingBox(new Rect(0,0,120,120)));
		getWorld().getPart(EntityTouchService.class).register(addPart(new PlayerTouchHandler()));
		
		SpriteDrawer spriteDrawer = addPart(new SpriteDrawer(
				new Animation[] {new StandAnim(),
						new PickUpRockAnim(),
						new ThrowRockAnim(),
						new WalkAnim()
				}));
		
		addPart(new ColorProperty(COLOR));
		
		addPart(new DrawDepth(DRAW_DEPTH));
		GamePart world = getWorld();
		world.getPart(DrawService.class).register(spriteDrawer);
		
	}
	
}
